<?php
class Exts_Views_Helpers_SeoUrl extends Zend_View_Helper_Abstract {
    public function seourl( $url )
    {
        $url = trim( $url );
        // Tranformamos todo a minusculas
        
        $url = strtolower($url);
        // Añaadimos los guiones
        
        $find = array(' ', '&', '\r\n', '\n', '+');
        $url = str_replace ($find, '-', $url);
        
        //Rememplazamos caracteres especiales latinos
        $find = array('á', 'é', 'í', 'ó', 'ú', 'ñ');
        
        $repl = array('a', 'e', 'i', 'o', 'u', 'n');
        
        $url = str_replace ($find, $repl, $url);
        
		// Eliminamos y Reemplazamos demás caracteres especiales
        
        $find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');
        
        $repl = array('', '-', '');
        
        $url = preg_replace ($find, $repl, $url);
        
        return $url;
    
    }
    
    public function clear_url($url) {
        
        $url=strtolower($url);
        $url=str_replace("á", "a",$url);
        $url=str_replace("é", "e",$url);
        $url=str_replace("í", "i",$url);
        $url=str_replace("ó", "o",$url);
        $url=str_replace("ú", "u",$url);
        $url=str_replace("ñ", "n",$url);
        $url=str_replace("?","",$url);
        $url=str_replace("¿","",$url);
        
        
        $url=str_replace(" ","aaabbbccc",$url);
        //$url=str_replace(" ","-",$url);
        
        $url=preg_replace("/[\W]/", "",$url);
        $url=str_replace("iquest","",$url);
        $url=str_replace("aaabbbccc","-",$url);
        $url=str_replace("--","-",$url);
        return $url;
    
    }

/*
    public function seoUrl( $str) {

        $s = strtolower($str);
        $s = ereg_replace("[áàâãäª@]","a",$s);
        $s = ereg_replace("[éèêë]","e",$s);
        $s = ereg_replace("[íìîï]","i",$s);
        $s = ereg_replace("[óòôõºö]","o",$s);
        $s = ereg_replace("[úùûü]","u",$s);
        $s = ereg_replace("[ç]","c",$s);
        $s = ereg_replace("[ñ]","n",$s);
        $s = preg_replace( "/[^a-zA-Z0-9\-]/", "-", $s );
        $s = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $s);
        return trim($s, '-');
    }

 */
}